home *** CD-ROM | disk | FTP | other *** search
- /************************************************************************/
- /* Project...: C++ and ANSI-C Compiler Environment */
- /* Name......: MWAbout.c */
- /* Purpose...: about box */
- /* Copyright.: ©Copyright 1993 by metrowerks inc. All rights reserved. */
- /************************************************************************/
-
- #include "About.h"
- #include <GestaltEqu.h>
- #include <QDOffscreen.h>
- #include <Sound.h>
-
- #define WIND_MetroAbout 1000
- #define PICT_Background 1000
- #define DITL_AboutItems 210
- #define Item_Background 0
- #define Item_BigBar 1
- #define Item_SmallBar 2
- #define Item_LogoBox 3
- #define Item_NameBox 4
- #define Item_CreditsBox 5
- #define Item_BigBarShadow 6
- #define Item_SmallBarShadow 7
- #define PICT_BigBar 1001
- #define PICT_BigBarShadow 2001
- #define PICT_SmallBar 1002
- #define PICT_SmallBarShadow 2002
- #define PICT_LogoBox 3001
- #define PICT_LogoHalf 3002
- #define PICT_LogoWhole 3003
- #define PICT_NameBox 3004
- #define PICT_Credits 1004
- #define snd_NameBoxClank 3004
- #define Bounce_Distance 10
- #define Fade_Levels 12
-
- typedef struct UserItemRec {
- long padding1;
- Rect box;
- short padding2;
- } UserItemRec;
-
- typedef struct DITLRec {
- short numItems;
- UserItemRec theUserItems[1];
- } DITLRec, **DITLHand;
-
- void DoAboutBox(void);
- void DoSimpleAbout(void);
- void SetUpGraphics(void);
- void DoAnimation(void);
- void CleanUpGraphics(void);
- void GetItemRect(short inItem, Rect *outRect);
- void DrawPictIntoNewGWorld(short inPICTid, short inDepth,
- GWorldPtr *outGWorldP);
-
- typedef enum AnimateState {
- animate_Waiting,
- animate_Active,
- animate_Done
- } AnimateState;
-
- void MoveOffWorld(GWorldPtr theGWorldP, Rect *currPos, Rect *newPos,
- Rect *imagePos);
- void MoveBar(GWorldPtr theGWorldP, GWorldPtr theShadowWorldP, Rect *inCurrPos,
- Rect *inShadowPos, short inHorizOffset);
- void MoveLogoBox(GWorldPtr theGWorldP, Rect *inCurrPos, short inVertOffset);
-
- typedef struct BarRec {
- GWorldPtr theGWorldP;
- GWorldPtr theShadowWorldP;
- Rect currPos;
- Rect shadowPos;
- } BarRec;
-
- void SetUpBigBar(BarRec *inBigBarRec);
- void SetUpSmallBar(BarRec *inSmallBarRec);
-
- typedef struct LogoRec {
- GWorldPtr theGWorldP;
- Rect currPos;
- Rect imagePos;
- short bottomLoc;
- } LogoRec;
-
- void SetUpLogoBox(LogoRec *inLogoBoxRec);
- void SetUpNameBox(LogoRec *inNameBoxRec);
-
- typedef struct CreditsRec {
- GWorldPtr theGWorldP;
- Rect viewRect;
- Rect pictRect;
- short pictHeight;
- } CreditsRec;
-
- void SetUpCredits(CreditsRec *inCreditsRec);
-
- static short Pixel_Depth;
- static CWindowPtr aboutBoxWindow;
- static PixMapPtr windowPixMapP;
- static GWorldPtr drawWorldP;
- static PixMapPtr drawPixMapP;
- static GWorldPtr backWorldP;
- static PixMapPtr backPixMapP;
-
- void DoAboutBox(void)
- {
- long qdVersion;
- GWorldPtr saveWorld;
- GDHandle saveDevice;
-
- Gestalt(gestaltQuickdrawVersion, &qdVersion);
-
- if ((qdVersion < gestalt32BitQD) || (FreeMem() < 350000)) {
- GrafPtr savePort;
- // Machine lacks 32bit QuickDraw or there's not enough memory.
- GetPort(&savePort);
-
- DoSimpleAbout();
-
- SetPort(savePort);
-
- } else { // OK to do animated about box.
-
- GetGWorld(&saveWorld, &saveDevice);
-
- SetUpGraphics();
-
- DoAnimation();
-
- CleanUpGraphics();
-
- PurgeMem(maxSize);
- SetGWorld(saveWorld, saveDevice);
- }
- }
-
- static void DoSimpleAbout(void)
- {
- WindowPtr macWindow = GetNewWindow(WIND_MetroAbout, nil, (WindowPtr) -1L);
- PicHandle thePicture;
- Rect r, picFrame;
- long ticks;
-
- SetPort(macWindow);
-
- thePicture = GetPicture(PICT_Background);
- if (thePicture != nil) {
- r = (**thePicture).picFrame;
-
- DrawPicture(thePicture, &r);
- ReleaseResource((Handle)thePicture);
- Delay(45, &ticks);
-
- thePicture = GetPicture(PICT_LogoWhole);
- GetItemRect(Item_LogoBox, &r);
- DrawPicture(thePicture, &r);
- ReleaseResource((Handle)thePicture);
- Delay(45, &ticks);
-
- thePicture = GetPicture(PICT_NameBox);
- GetItemRect(Item_NameBox, &r);
- DrawPicture(thePicture, &r);
- ReleaseResource((Handle)thePicture);
- Delay(45, &ticks);
-
- thePicture = GetPicture(PICT_Credits);
- picFrame = (**thePicture).picFrame;
- GetItemRect(Item_CreditsBox, &r);
- OffsetRect(&picFrame, r.left, r.top);
- ClipRect(&r);
- DrawPicture(thePicture, &picFrame);
- ReleaseResource((Handle)thePicture);
-
- while (!Button())
- ;
- }
- DisposeWindow(macWindow);
- }
-
- static void SetUpGraphics(void)
- {
- Rect backRect;
- PixMapHandle thePixMapH;
-
- Pixel_Depth = 8;
-
- // Make GWorld for offscreen drawing.
-
- GetItemRect(Item_Background, &backRect);
- NewGWorld(&drawWorldP, Pixel_Depth, &backRect, nil, nil, 0);
- thePixMapH = GetGWorldPixMap(drawWorldP);
- HLockHi((Handle)thePixMapH);
- LockPixels(thePixMapH);
- drawPixMapP = *thePixMapH;
-
- // Make GWorld for background.
-
- DrawPictIntoNewGWorld(PICT_Background, Pixel_Depth, &backWorldP);
- thePixMapH = GetGWorldPixMap(backWorldP);
- HLockHi((Handle)thePixMapH);
- LockPixels(thePixMapH);
- backPixMapP = *thePixMapH;
-
- // Make Window.
-
- aboutBoxWindow = (CWindowPtr) GetNewCWindow(WIND_MetroAbout, nil,
- (WindowPtr) - 1L);
- HLockHi((Handle)aboutBoxWindow->portPixMap);
- windowPixMapP = *aboutBoxWindow->portPixMap;
-
- // Draw background in Window.
-
- SetGWorld(aboutBoxWindow, GetMainDevice());
- CopyBits((BitMapPtr)backPixMapP, (BitMapPtr)windowPixMapP, &backRect, &backRect, srcCopy, nil);
- }
-
- void SetUpBigBar(BarRec *inBigBarRec)
- {
- DrawPictIntoNewGWorld(PICT_BigBar, Pixel_Depth, &inBigBarRec->theGWorldP);
- DrawPictIntoNewGWorld(PICT_BigBarShadow, Pixel_Depth,
- &inBigBarRec->theShadowWorldP);
-
- GetItemRect(Item_BigBar, &inBigBarRec->currPos);
- GetItemRect(Item_BigBarShadow, &inBigBarRec->shadowPos);
-
- OffsetRect(&inBigBarRec->currPos, -inBigBarRec->shadowPos.right, 0);
- OffsetRect(&inBigBarRec->shadowPos, -inBigBarRec->shadowPos.right, 0);
- }
-
- void SetUpSmallBar(BarRec *inSmallBarRec)
- {
- short barWidth;
-
- DrawPictIntoNewGWorld(PICT_SmallBar, Pixel_Depth,
- &inSmallBarRec->theGWorldP);
- DrawPictIntoNewGWorld(PICT_SmallBarShadow, Pixel_Depth,
- &inSmallBarRec->theShadowWorldP);
-
- GetItemRect(Item_SmallBar, &inSmallBarRec->currPos);
- GetItemRect(Item_SmallBarShadow, &inSmallBarRec->shadowPos);
-
- barWidth = inSmallBarRec->currPos.right - inSmallBarRec->currPos.left;
-
- inSmallBarRec->currPos.left = inSmallBarRec->currPos.right;
- inSmallBarRec->currPos.right += barWidth;
-
- OffsetRect(&inSmallBarRec->shadowPos, barWidth, 0);
- }
-
- void SetUpLogoBox(LogoRec *inLogoBoxRec)
- {
- GetItemRect(Item_LogoBox, &inLogoBoxRec->currPos);
- inLogoBoxRec->bottomLoc = inLogoBoxRec->currPos.bottom;
- OffsetRect(&inLogoBoxRec->currPos, 0, -inLogoBoxRec->currPos.bottom);
- }
-
- void SetUpNameBox(LogoRec *inNameBoxRec)
- {
- DrawPictIntoNewGWorld(PICT_NameBox, Pixel_Depth,
- &inNameBoxRec->theGWorldP);
-
- GetItemRect(Item_NameBox, &inNameBoxRec->currPos);
- inNameBoxRec->bottomLoc = inNameBoxRec->currPos.bottom;
- OffsetRect(&inNameBoxRec->currPos, 0, -inNameBoxRec->currPos.bottom);
- inNameBoxRec->imagePos.left = inNameBoxRec->imagePos.top = 0;
- inNameBoxRec->imagePos.right = inNameBoxRec->currPos.right -
- inNameBoxRec->currPos.left;
- inNameBoxRec->imagePos.bottom = inNameBoxRec->currPos.bottom -
- inNameBoxRec->currPos.top;
- }
-
- void SetUpCredits(CreditsRec *inCreditsRec)
- {
- PicHandle pictureH;
- Rect picFrame;
- PixMapHandle thePixMapH;
-
- // The only animation is the credits
- // Therefore, we can reduce the size of the offscreen worlds for the background
- // and scratch drawing to just cover the area where the credits are drawn.
-
- DisposeGWorld(backWorldP);
- DisposeGWorld(drawWorldP);
-
- GetItemRect(Item_CreditsBox, &inCreditsRec->viewRect);
-
- // Make GWorld for offscreen drawing.
-
- NewGWorld(&drawWorldP, Pixel_Depth, &inCreditsRec->viewRect, nil, nil, 0);
- thePixMapH = GetGWorldPixMap(drawWorldP);
- HLockHi((Handle)thePixMapH);
- LockPixels(thePixMapH);
- drawPixMapP = *thePixMapH;
-
- // Make GWorld for background.
-
- NewGWorld(&backWorldP, Pixel_Depth, &inCreditsRec->viewRect, nil,
- GetGWorldDevice(drawWorldP), noNewDevice);
- thePixMapH = GetGWorldPixMap(backWorldP);
- HLockHi((Handle)thePixMapH);
- LockPixels(thePixMapH);
- backPixMapP = *thePixMapH;
- SetGWorld(backWorldP, nil);
- pictureH = GetPicture(PICT_Background);
- picFrame = (**pictureH).picFrame;
- DrawPicture(pictureH, &picFrame);
- ReleaseResource((Handle)pictureH);
-
- // Make GWorld for credits.
-
- DrawPictIntoNewGWorld(PICT_Credits, Pixel_Depth,
- &inCreditsRec->theGWorldP);
-
- inCreditsRec->pictRect.left = 0;
- inCreditsRec->pictRect.top = 0;
- inCreditsRec->pictRect.right = inCreditsRec->viewRect.right -
- inCreditsRec->viewRect.left;
- inCreditsRec->pictRect.bottom = inCreditsRec->viewRect.bottom -
- inCreditsRec->viewRect.top;
-
- pictureH = GetPicture(PICT_Credits);
- inCreditsRec->pictHeight = (**pictureH).picFrame.bottom;
- ReleaseResource((Handle)pictureH);
- }
-
- void MoveBar(GWorldPtr theGWorldP, GWorldPtr theShadowWorldP, Rect *inCurrPos,
- Rect *inShadowPos, short inHorizOffset)
- {
- Rect exposedRect, coveredRect, imageRect;
- Rect shadowFront, shadowBack;
- PixMapHandle offPixMapH;
-
- // Draw to the Window.
-
- SetGWorld(aboutBoxWindow, GetMainDevice());
-
- // Determine areas exposed and covered by bar as it moves.
-
- exposedRect = coveredRect = *inCurrPos;
- shadowFront = shadowBack = *inShadowPos;
- if (inHorizOffset > 0) {
- exposedRect.right = exposedRect.left + inHorizOffset;
- coveredRect.left = coveredRect.right;
- coveredRect.right += inHorizOffset;
- shadowBack.right = shadowBack.left + inHorizOffset;
- shadowBack.top = coveredRect.bottom;
- shadowFront.left = shadowFront.right;
- shadowFront.right += inHorizOffset;
- } else {
- exposedRect.left = exposedRect.right + inHorizOffset;
- exposedRect.bottom = shadowBack.top;
- coveredRect.right = coveredRect.left;
- coveredRect.left += inHorizOffset;
- shadowBack.left = shadowBack.right + inHorizOffset;
- shadowFront.right = shadowFront.left;
- shadowFront.left += inHorizOffset;
- shadowFront.top = coveredRect.bottom;
- }
- imageRect.left = coveredRect.left;
- imageRect.right = coveredRect.right;
- imageRect.top = 0;
- imageRect.bottom = coveredRect.bottom - coveredRect.top;
-
- // Restore background over exposed area.
-
- CopyBits((BitMapPtr)backPixMapP, (BitMapPtr)windowPixMapP, &exposedRect, &exposedRect, srcCopy,
- nil);
- CopyBits((BitMapPtr)backPixMapP, (BitMapPtr)windowPixMapP, &shadowBack, &shadowBack, srcCopy,
- nil);
-
- // Draw image at covered area.
-
- offPixMapH = GetGWorldPixMap(theGWorldP);
- LockPixels(offPixMapH);
- CopyBits ((BitMapPtr)(*offPixMapH), (BitMapPtr)windowPixMapP, &imageRect, &coveredRect, srcCopy,
- nil);
- UnlockPixels(offPixMapH);
-
- offPixMapH = GetGWorldPixMap(theShadowWorldP);
- LockPixels(offPixMapH);
- CopyBits ((BitMapPtr)(*offPixMapH), (BitMapPtr)windowPixMapP, &shadowFront, &shadowFront, srcCopy,
- nil);
- if (inHorizOffset < 0) {
- shadowFront.left = exposedRect.left;
- shadowFront.right = exposedRect.right;
- shadowFront.top = shadowBack.top;
- CopyBits ((BitMapPtr)(*offPixMapH), (BitMapPtr)windowPixMapP, &shadowFront, &shadowFront,
- srcCopy, nil);
- }
- UnlockPixels(offPixMapH);
- }
-
- void MoveLogoBox(GWorldPtr theGWorldP, Rect *inCurrPos, short inVertOffset)
- {
- Rect exposedRect, coveredRect, imageRect;
- RGBColor boxColor = {
- 65535, 52428, 0
- };
-
- // Draw to the Window.
-
- SetGWorld(aboutBoxWindow, GetMainDevice());
-
- // Determine areas exposed and covered by bar as it moves.
-
- exposedRect = coveredRect = *inCurrPos;
- if (inVertOffset > 0) {
- exposedRect.bottom = exposedRect.top + inVertOffset;
- coveredRect.top = coveredRect.bottom;
- coveredRect.bottom += inVertOffset;
- } else {
- exposedRect.top = exposedRect.bottom + inVertOffset;
- coveredRect.bottom = coveredRect.top;
- coveredRect.top += inVertOffset;
- }
- imageRect.left = 0;
- imageRect.right = coveredRect.right - coveredRect.left;
- imageRect.top = 0;
- imageRect.bottom = coveredRect.bottom - coveredRect.top;
-
- // Restore background over exposed area.
-
- CopyBits((BitMapPtr)backPixMapP, (BitMapPtr)windowPixMapP, &exposedRect, &exposedRect, srcCopy,
- nil);
-
- // Draw image at covered area.
-
- RGBForeColor(&boxColor);
- PaintRect(&coveredRect);
- ForeColor(blackColor);
- }
-
- void MoveOffWorld(GWorldPtr theGWorldP, Rect *inCurrPos, Rect *inNewPos,
- Rect *inOffPos)
- {
- Rect drawRect;
- PixMapHandle offPixMapH;
-
- // Create image in draw world.
-
- SetGWorld(drawWorldP, nil);
-
- // Restore background at current position.
-
- CopyBits((BitMapPtr)backPixMapP, (BitMapPtr)drawPixMapP, inCurrPos, inCurrPos, srcCopy, nil);
-
- // Draw image at new position.
-
- offPixMapH = GetGWorldPixMap(theGWorldP);
- LockPixels(offPixMapH);
- CopyBits ((BitMapPtr)(*offPixMapH), (BitMapPtr)drawPixMapP, inOffPos, inNewPos, srcCopy, nil);
- UnlockPixels(offPixMapH);
-
- // Draw union of old and new position to Window.
-
- SetGWorld(aboutBoxWindow, GetMainDevice());
- UnionRect(inCurrPos, inNewPos, &drawRect);
- CopyBits((BitMapPtr)drawPixMapP, (BitMapPtr)windowPixMapP, &drawRect, &drawRect, srcCopy, nil);
- }
-
- static void DoAnimation(void)
- {
- BarRec theBigBarRec;
- BarRec theSmallBarRec;
- LogoRec theLogoBoxRec;
- LogoRec theNameBoxRec;
- CreditsRec theCreditsRec;
-
- Rect currPos, imagePos;
-
- PicHandle thePictureH;
- SndChannelPtr theSoundChannelP = nil;
- Handle theSoundH = nil;
-
- AnimateState animBigBar = animate_Active;
- AnimateState animSmallBar = animate_Waiting;
- AnimateState animLogoBoxDown = animate_Waiting;
- AnimateState animLogoBoxUp = animate_Waiting;
- AnimateState animNameBoxDown = animate_Waiting;
- AnimateState animNameBoxUp = animate_Waiting;
- AnimateState animCreditsFade = animate_Waiting;
- AnimateState animCreditsScroll = animate_Waiting;
-
- Boolean logoHalfDrawn = false;
- Boolean logoWholeDrawn = false;
-
- RGBColor fadeColor;
- short grayIndex = 0;
- unsigned short grayLevels[Fade_Levels] = {
- 4369, 8738, 17476, 21845, 30583, 34952, 43690, 48059, 52428, 56979,
- 61166, 65535
- };
-
- theBigBarRec.theGWorldP = nil;
- theBigBarRec.theShadowWorldP = nil;
- theSmallBarRec.theGWorldP = nil;
- theSmallBarRec.theShadowWorldP = nil;
- theLogoBoxRec.theGWorldP = nil;
- theNameBoxRec.theGWorldP = nil;
- theCreditsRec.theGWorldP = nil;
-
- SetUpBigBar(&theBigBarRec);
- SetUpLogoBox(&theLogoBoxRec);
- theSoundH = GetResource('snd ', snd_NameBoxClank);
- theSmallBarRec.currPos.left = 1000;
-
- while (!Button()) {
- long ticks;
- long endTicks;
- long startTicks = TickCount();
-
- if ((animLogoBoxDown == animate_Waiting) &&
- (theBigBarRec.currPos.left > 100)) {
- animLogoBoxDown = animate_Active;
- }
- if ((animLogoBoxDown == animate_Active) &&
- (theLogoBoxRec.currPos.bottom >=
- theLogoBoxRec.bottomLoc + Bounce_Distance)) {
- animLogoBoxDown = animate_Done;
- animLogoBoxUp = animate_Active;
- }
- if ((animLogoBoxUp == animate_Active) &&
- (theLogoBoxRec.currPos.bottom <= theLogoBoxRec.bottomLoc)) {
- animLogoBoxUp = animate_Done;
- }
- if ((animBigBar == animate_Active) && !logoHalfDrawn &&
- (theBigBarRec.currPos.right > theLogoBoxRec.currPos.right)) {
- SetGWorld(backWorldP, nil);
- thePictureH = GetPicture(PICT_LogoHalf);
- DrawPicture(thePictureH, &theLogoBoxRec.currPos);
- ReleaseResource((Handle)thePictureH);
- logoHalfDrawn = true;
- }
- if ((animBigBar == animate_Active) &&
- theBigBarRec.currPos.left > backWorldP->portRect.right) {
- animBigBar = animate_Done;
- DisposeGWorld(theBigBarRec.theGWorldP);
- theBigBarRec.theGWorldP = nil;
- DisposeGWorld(theBigBarRec.theShadowWorldP);
- theBigBarRec.theShadowWorldP = nil;
- animSmallBar = animate_Active;
- SetUpSmallBar(&theSmallBarRec);
- }
- if ((animSmallBar == animate_Active) && !logoWholeDrawn &&
- (theSmallBarRec.currPos.left < theLogoBoxRec.currPos.left)) {
- SetGWorld(backWorldP, nil);
- thePictureH = GetPicture(PICT_LogoWhole);
- DrawPicture(thePictureH, &theLogoBoxRec.currPos);
- ReleaseResource((Handle)thePictureH);
- logoWholeDrawn = true;
- }
- if ((animNameBoxDown == animate_Waiting) &&
- (theSmallBarRec.currPos.left < 150)) {
- animNameBoxDown = animate_Active;
- SetUpNameBox(&theNameBoxRec);
- }
- if ((animNameBoxDown == animate_Active) &&
- (theNameBoxRec.currPos.bottom >=
- theNameBoxRec.bottomLoc + Bounce_Distance)) {
- animNameBoxDown = animate_Done;
- animNameBoxUp = animate_Active;
- }
- if ((animNameBoxUp == animate_Active) &&
- (theNameBoxRec.currPos.bottom <= theNameBoxRec.bottomLoc)) {
- OSErr err;
- animNameBoxUp = animate_Done;
- DisposeGWorld(theNameBoxRec.theGWorldP);
- theNameBoxRec.theGWorldP = nil;
- if (theSoundH != nil) {
- err = SndNewChannel(&theSoundChannelP, sampledSynth, initMono,
- nil);
- if (err == noErr)
- SndPlay(theSoundChannelP, theSoundH, true);
- }
- }
- if ((animSmallBar == animate_Active) &&
- (theSmallBarRec.shadowPos.right < backWorldP->portRect.left)) {
- animSmallBar = animate_Done;
- DisposeGWorld(theSmallBarRec.theGWorldP);
- theSmallBarRec.theGWorldP = nil;
- DisposeGWorld(theSmallBarRec.theShadowWorldP);
- theSmallBarRec.theShadowWorldP = nil;
-
- if (theSoundChannelP != nil) {
- SndDisposeChannel(theSoundChannelP, true);
- theSoundChannelP = nil;
- }
- if (theSoundH != nil) {
- ReleaseResource(theSoundH);
- theSoundH = nil;
- }
- animCreditsFade = animate_Active;
- SetUpCredits(&theCreditsRec);
- }
- if ((animCreditsFade == animate_Active) &&
- (grayIndex >= Fade_Levels)) {
- animCreditsFade = animate_Done;
- Delay(90, &ticks);
- animCreditsScroll = animate_Active;
- }
- if ((animCreditsScroll == animate_Active) &&
- (theCreditsRec.pictRect.top > theCreditsRec.pictHeight)) {
- theCreditsRec.pictRect.top = 1;
- theCreditsRec.pictRect.bottom = theCreditsRec.viewRect.bottom -
- theCreditsRec.viewRect.top + 1;
- }
- if (animBigBar == animate_Active) {
- MoveBar(theBigBarRec.theGWorldP, theBigBarRec.theShadowWorldP,
- &theBigBarRec.currPos, &theBigBarRec.shadowPos, 1);
- theBigBarRec.currPos.left++;
- theBigBarRec.currPos.right++;
- theBigBarRec.shadowPos.left++;
- theBigBarRec.shadowPos.right++;
- }
- if (animLogoBoxDown == animate_Active) {
- MoveLogoBox(theLogoBoxRec.theGWorldP, &theLogoBoxRec.currPos, 1);
- theLogoBoxRec.currPos.top++;
- theLogoBoxRec.currPos.bottom++;
- }
- if (animLogoBoxUp == animate_Active) {
- MoveLogoBox(theLogoBoxRec.theGWorldP, &theLogoBoxRec.currPos, -1);
- theLogoBoxRec.currPos.top--;
- theLogoBoxRec.currPos.bottom--;
- }
- if (animSmallBar == animate_Active) {
- MoveBar(theSmallBarRec.theGWorldP, theSmallBarRec.theShadowWorldP,
- &theSmallBarRec.currPos, &theSmallBarRec.shadowPos, -1);
- theSmallBarRec.currPos.left--;
- theSmallBarRec.currPos.right--;
- theSmallBarRec.shadowPos.left--;
- theSmallBarRec.shadowPos.right--;
- }
- if (animNameBoxDown == animate_Active) {
- currPos = theNameBoxRec.currPos;
- theNameBoxRec.currPos.top++;
- theNameBoxRec.currPos.bottom++;
- imagePos = theNameBoxRec.imagePos;
- MoveOffWorld(theNameBoxRec.theGWorldP, &currPos,
- &theNameBoxRec.currPos, &imagePos);
- }
- if (animNameBoxUp == animate_Active) {
- currPos = theNameBoxRec.currPos;
- theNameBoxRec.currPos.top--;
- theNameBoxRec.currPos.bottom--;
- imagePos = theNameBoxRec.imagePos;
- MoveOffWorld(theNameBoxRec.theGWorldP, &currPos,
- &theNameBoxRec.currPos, &imagePos);
- }
- if (animCreditsFade == animate_Active) {
- PixMapHandle thePixMapH;
-
- Delay(3, &ticks);
- SetGWorld(drawWorldP, nil);
-
- thePixMapH = GetGWorldPixMap(theCreditsRec.theGWorldP);
- LockPixels(thePixMapH);
- CopyBits ((BitMapPtr)(*thePixMapH), (BitMapPtr)drawPixMapP, &theCreditsRec.pictRect,
- &theCreditsRec.viewRect, srcCopy, nil);
- UnlockPixels(thePixMapH);
-
- fadeColor.red = fadeColor.blue = fadeColor.green =
- grayLevels[grayIndex++];
- RGBForeColor(&fadeColor);
- PenMode(adMin);
- PaintRect(&theCreditsRec.viewRect);
- PenMode(patCopy);
- ForeColor(blackColor);
-
- CopyBits((BitMapPtr)backPixMapP, (BitMapPtr)drawPixMapP, &theCreditsRec.viewRect,
- &theCreditsRec.viewRect, adMax, nil);
-
- SetGWorld(aboutBoxWindow, GetMainDevice());
- CopyBits((BitMapPtr)drawPixMapP, (BitMapPtr)windowPixMapP, &theCreditsRec.viewRect,
- &theCreditsRec.viewRect, srcCopy, nil);
- }
- if (animCreditsScroll == animate_Active) {
- PixMapHandle thePixMapH;
- short i, j;
- short creditsWidth =
- theCreditsRec.viewRect.right -theCreditsRec.viewRect.left -1;
- Rect wrapViewRect, wrapPictRect;
-
- SetGWorld(drawWorldP, nil);
-
- theCreditsRec.pictRect.top += 1;
- theCreditsRec.pictRect.bottom += 1;
-
- thePixMapH = GetGWorldPixMap(theCreditsRec.theGWorldP);
- LockPixels(thePixMapH);
- if (theCreditsRec.pictRect.bottom <= theCreditsRec.pictHeight) {
- CopyBits ((BitMapPtr)(*thePixMapH), (BitMapPtr)drawPixMapP, &theCreditsRec.pictRect,
- &theCreditsRec.viewRect, srcCopy, nil);
- } else {
- wrapViewRect = theCreditsRec.viewRect;
- wrapViewRect.top = wrapViewRect.bottom -
- (theCreditsRec.pictRect.bottom -
- theCreditsRec.pictHeight);
- wrapPictRect = theCreditsRec.pictRect;
- wrapPictRect.top = 0;
- wrapPictRect.bottom = wrapPictRect.top +
- (wrapViewRect.bottom - wrapViewRect.top);
- CopyBits ((BitMapPtr)(*thePixMapH), (BitMapPtr)drawPixMapP, &theCreditsRec.pictRect,
- &theCreditsRec.viewRect, srcCopy, nil);
- CopyBits ((BitMapPtr)(*thePixMapH), (BitMapPtr)drawPixMapP, &wrapPictRect,
- &wrapViewRect, srcCopy, nil);
- }
- UnlockPixels(thePixMapH);
-
- PenMode(adMin);
- j = Fade_Levels - 1;
- for (i = 0; i < j; i++) {
- fadeColor.red = fadeColor.blue = fadeColor.green =
- grayLevels[i];
- RGBForeColor(&fadeColor);
- MoveTo(theCreditsRec.viewRect.left,
- theCreditsRec.viewRect.top + i);
- Line(creditsWidth, 0);
- MoveTo(theCreditsRec.viewRect.left,
- theCreditsRec.viewRect.bottom - i - 1);
- Line(creditsWidth, 0);
- }
- ForeColor(blackColor);
- PenMode(patCopy);
-
- CopyBits((BitMapPtr)backPixMapP, (BitMapPtr)drawPixMapP, &theCreditsRec.viewRect,
- &theCreditsRec.viewRect, adMax, nil);
- SetGWorld(aboutBoxWindow, GetMainDevice());
- CopyBits((BitMapPtr)drawPixMapP, (BitMapPtr)windowPixMapP, &theCreditsRec.viewRect,
- &theCreditsRec.viewRect, srcCopy, nil);
- }
- endTicks = TickCount(); // Timing loop.
- if (endTicks == startTicks) { // TickCount must change during each pass thru animation loop.
- while (endTicks == TickCount())
- ; // this puts an upper speed limit on the animation rate.
- }
- }
-
- // Finished animation (user clicked). Flush the mousedown events
-
- FlushEvents(mDownMask | mUpMask | keyDownMask | keyUpMask | autoKeyMask,0);
-
- // Dispose of all GWorlds (if they haven't already been disposed).
-
- if (theBigBarRec.theGWorldP != nil)
- DisposeGWorld(theBigBarRec.theGWorldP);
- if (theBigBarRec.theShadowWorldP != nil)
- DisposeGWorld(theBigBarRec.theShadowWorldP);
- if (theSmallBarRec.theGWorldP != nil)
- DisposeGWorld(theSmallBarRec.theGWorldP);
- if (theSmallBarRec.theShadowWorldP != nil)
- DisposeGWorld(theSmallBarRec.theShadowWorldP);
- if (theLogoBoxRec.theGWorldP != nil)
- DisposeGWorld(theLogoBoxRec.theGWorldP);
- if (theNameBoxRec.theGWorldP != nil)
- DisposeGWorld(theNameBoxRec.theGWorldP);
- if (theCreditsRec.theGWorldP != nil)
- DisposeGWorld(theCreditsRec.theGWorldP);
-
- if (theSoundChannelP != nil)
- SndDisposeChannel(theSoundChannelP, true);
- if (theSoundH != nil)
- ReleaseResource(theSoundH);
- }
-
- static void CleanUpGraphics(void)
- {
- DisposeGWorld(drawWorldP);
- DisposeGWorld(backWorldP);
- DisposeWindow((WindowPtr)aboutBoxWindow);
- }
-
- void GetItemRect(short inItem, Rect *outRect)
- {
- DITLHand theDITL;
-
- theDITL = (DITLHand) GetResource('DITL', DITL_AboutItems);
- *outRect = (**theDITL).theUserItems[inItem].box;
- }
-
- void DrawPictIntoNewGWorld(short inPICTid, short inDepth,
- GWorldPtr *outGWorldP)
- {
- PicHandle thePicture;
- Rect picFrame;
- GWorldPtr saveWorld;
- GDHandle saveDevice;
- OSErr err;
-
- thePicture = GetPicture(inPICTid);
- picFrame = (**thePicture).picFrame;
-
- err = NewGWorld(outGWorldP, inDepth, &picFrame, nil,
- GetGWorldDevice(drawWorldP), noNewDevice);
- if (err != noErr)
- Debugger();
-
- GetGWorld(&saveWorld, &saveDevice);
- SetGWorld (*outGWorldP, nil);
- DrawPicture(thePicture, &picFrame);
- SetGWorld(saveWorld, saveDevice);
-
- ReleaseResource((Handle)thePicture);
- }
-